$(function() {
	$('#vue_vm_list div').hide();
});

var cgSendOrder = {
	cgSendOrderId: '',
	caregiverId: '',
	caregiverName: '',
	elderId: '',
	elderName: '',
	nursingCostId: '',
	nursingCostName: '',
	nursingCostPrice: '',
	caregiverSendOrdersStandardId: '',
	orderStandardName: '',
	orderStandardSalary: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
	status: '',
	subjectRoomId: getLoginedUser().subjectRoomId,
	subjectRoomName: getLoginedUser().subjectRoomName
};

var view = {
	data: cgSendOrder
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function save() {
	view.data.caregiverId = $('input:radio[name="caregiverId"]:checked').val();
	view.data.caregiverName = $('input:radio[name="caregiverId"]:checked').attr('caregiverName');
	view.data.nursingCostName = $('#nursingCost_select option:selected').text();
	view.data.caregiverSendOrdersStandardId = $('input:radio[name="caregiverId"]:checked').attr('caregiverSendOrdersStandardId');
	view.data.orderStandardName = $('input:radio[name="caregiverId"]:checked').attr('orderStandardName');
	
	if(!view.data.caregiverId) {
		alert('请选择护理员');
		return;
	}
	
	view.data.subjectRoomId = getLoginedUser().subjectRoomId;
	view.data.subjectRoomName = getLoginedUser().subjectRoomName;
	view.data.nursingCostPrice = (view.data.nursingCostPrice==''? 0: parseFloat(view.data.nursingCostPrice));
	view.data.orderStandardSalary = (view.data.orderStandardSalary==''? 0: parseFloat(view.data.orderStandardSalary));
	view.data.status = (view.data.status==''? 0: parseInt(view.data.status));

	save_basic(path+'/cgSendOrder/save', {cgSendOrder:view.data}, function() {
		alert('保存成功');
	});
}

function loadCgSendOrderBySubjectRoomId(subjectRoomId) {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();

	find_basic_by_json(path+'/cgSendOrder/findBySubjectRoomId', {subjectRoomId: subjectRoomId}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function loadCgSendOrderByCond() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();
	
	var searchVal = $('#searchVal').val();
	find_basic_by_json(path+'/cgSendOrder/findCaregiverDetail',
			{searchVal: searchVal, subjectRoomId: getLoginedUser().subjectRoomId}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/cgSendOrder/deleteBatch');
}
